<template>
  <!--输入礼品卡激活码页面-->
  <div class="lipinkajihuo">
    <p><img src="../../../assets/jihuobanner.png" alt="" width="100%"></p>
    <wv-group>
      <wv-input label="会员权益" placeholder="请输入激活码" type="number" v-model="activateCode"></wv-input>
    </wv-group>
    <p class="offer" @click="goActivateGiftcard(activateCode)">激活</p>
    <div class="model" v-show="isvisible">
      <div class="bg"></div>
      <div class="modelContent buzu">
        <img src="../../../assets/close.png" alt="" width="15" @click="isvisible=false">
        激活码错误，请重新输入
        <p class="btn">
          <button @click="isvisible=false">确定</button>
        </p>
      </div>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
  import {activateGiftcard} from '../../../../test/unit/http'
  import {Toast} from 'we-vue'
  export default {
    name: 'jihuoform',
    props: {},
    data() {
      return {
        isvisible: false,
        activateCode: ""
      };
    },
    methods: {
      goActivateGiftcard(activateCode){
        if(this.$myUtils.isNull(activateCode)){
          Toast.text("请填写激活码");
          return;
        }
        let params = {activateCode: activateCode};
        activateGiftcard(params).then(res => {
          console.log(res);
          if (res.code == 100) {
            var accountGoodsId = res.object.accountGoodsId;
            this.$router.push({path: 'wanshanziliao', query: {accountGoodsId:accountGoodsId,type:1}})

          } else {
            Toast.fail(res.info)
          }
        })
      }
    },
    created() {

    },
    components: {}
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less" rel="stylesheet/less">
  .bg {
    background-color: rgba(0, 0, 0, 0.3);
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 50px;
  }

  .model .modelContent {
    background-color: #fff;
    border-radius: 8px;
    position: fixed;
    left: 50%;
    top: 50%;
    margin-left: -43%;
    margin-top: -111px;
    z-index: 2;
    padding: 40px 10px 20px;
    width: 80%;
    text-align: center;
    img {
      position: absolute;
      right: 10px;
      top: 10px
    }
    .btn {
      button {
        height: 42px;
        line-height: 42px;
        color: #fff;
        outline: none;
        border: none;
        width: 100%;
        border-radius: 8px;
        margin-top: 25px;
        background-color: #2f95f0;
      }
    }

  }

  .weui-cell {
    background-color: #eee;
    height: 48px;
    line-height: 48px;
    border-radius: 5px;
    width: 80%;
    margin: auto;
  }

  .offer {
    position: fixed;
    bottom: 0;
    width: 100%;
    background-image: linear-gradient(to left, #4c92ed, #61beec);
    height: 50px;
    line-height: 50px;
    color: #fff;
  }
</style>
